home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / archive / userbox / publicdomain / gedscanner.lha / GedScanner / HeaderScan.asm < prev    next >
Assembly Source File  |  1996-07-22  |  2KB  |  105 lines

  1. ; GoldED scanner for header files
  2. ; it recognizes #define, struct and `function` entrys
  3.  
  4.             movem.l a1-a2/d1-d3,-(SP)
  5.             move.l  d0,d1           ; remember length
  6.         moveq.l #0,d0
  7.         moveq.l #0,d2
  8.             movea.l (a0),a1
  9.         cmpi.b    #"#",(a1)
  10.         beq    def        ; searching defines...
  11.         cmpi.b    #" ",(a1)
  12.         beq    end        ; should not start with ' '
  13.         cmpi.b    #"*",(a1)
  14.         beq    end        ; should not start with '*'
  15.  
  16.                     
  17. bracket      cmpi.b    #"/",(a1)     
  18.         beq    struc
  19.         cmpi.b    #"-",(a1)
  20.         beq    struc
  21.         cmpi.b    #"+",(a1)
  22.         beq    struc
  23.         cmpi.b    #"(",(a1)+
  24.         beq    funct
  25.         cmp.b    d2,d1
  26.         beq    struc
  27.         addq.b    #1,d2
  28.         bra    bracket
  29.  
  30. funct        cmpi.b    #0,-(a1)    ; 
  31. functloop    cmpi.b    #0,d2
  32.         beq    end
  33.         subq.b    #1,d2
  34.         cmpi.b    #" ",-(a1)    
  35.         beq    functloop
  36.         cmpi.b    #9,(a1)
  37.         bne    nameend
  38.         bra    functloop
  39.  
  40. nameend        move.b    d2,d3        ; remember offset
  41. nameloop    cmpi.b    #0,d2
  42.         beq    namefini
  43.         subq.b    #1,d2                        
  44.         cmpi.b    #" ",-(a1)
  45.         beq    namefini
  46.         cmpi.b    #9,(a1)
  47.         beq    namefini
  48.         cmpi.b    #"*",(a1)
  49.         beq    namefini
  50.         bra    nameloop
  51. namefini    cmpi.b    #0,(a1)+
  52.         move.l    a1,(a0)
  53.         move.b    d3,d0
  54.         sub.b    d2,d0
  55.         bra    end
  56.  
  57. def         lea    defstr,a2    ; searching defines
  58.         bra    search
  59.  
  60. struc        movea.l    (a0),a1
  61.         moveq.l    #0,d0
  62.         moveq.l    #0,d2
  63.         cmpi.b  #"s",(a1)       ; searching struct
  64.             bne     end
  65.         lea    structstr,a2
  66.  
  67. search      cmpi.b  #0,(a2)
  68.             beq     found           
  69.             cmp.b    d2,d1
  70.         beq    end
  71.         addq.l  #1,d2
  72.         cmpm.b  (a2)+,(a1)+
  73.             bne     end            ; nothing found
  74.             bra     search
  75.     
  76. found       cmp.b      d2,d1
  77.             beq    end
  78.         addq.b    #1,d2
  79.          cmpi.b  #" ",(a1)+    
  80.             beq     found
  81.             cmpi.b    #0,-(a1)
  82.         cmpi.b    #9,(a1)+
  83.         beq    found
  84.         suba.l  #1,a1
  85.             move.l  a1,(a0)         ; namestart
  86. loop        cmpi.b  #"(",(a1)       ; calculate length 
  87.             beq     end
  88.         cmpi.b    #" ",(a1)
  89.         beq    end
  90.         cmpi.b    #10,(a1)
  91.         beq    end
  92.         cmpi.b    #9,(a1)+
  93.         beq    end
  94.             addq.l  #1,d0
  95.         cmp.b    d2,d1
  96.         beq    end
  97.         addq.b    #1,d2
  98.         bra loop
  99.  
  100. end            movem.l (SP)+,a1-a2/d1-d3
  101.             rts
  102.  
  103. defstr        dc.b      '#define',0
  104. structstr     dc.b    'struct',0
  105.